﻿@{
    ViewData["Title"] = "Index";
    Layout = "~/Areas/Console/Views/Shared/_Layout.cshtml";
}
@section head{
    @*  <style>
        .layui-table tbody .layui-table-cell {
            height: 60px;
        }
    </style>*@
    <script type="text/javascript">
        var renderTable;
        var setSelectData;
        var userType = 0;

        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            treetable: 'treetable-lay/treetable',
            index: 'lib/index'
        }).use(['table', 'treetable', 'index', 'laydate', 'form'], function () {
            var $ = layui.$
                , form = layui.form
                , admin = layui.admin
                , table = layui.table
                , element = layui.element
                , laydate = layui.laydate;

            //日期范围
            laydate.render({
                elem: '#changeTime'
                , range: true
            });

            ////操作类型
            //$.getJSON("/Assets/GetCode?type=operationType", function (result) {
            //    $('#operationType').append(new Option(top.lang.pleaseSelect, ""));
            //    let plat = result.data;
            //    plat.forEach(function (v) {
            //        for (var key in top.lang) {
            //            if (top.lang.hasOwnProperty(key)) {
            //                if (key === v.remark) {
            //                    var text = top.lang[key];
            //                    $('#operationType').append(new Option(text, v.remark));
            //                }
            //            }
            //        }
            //    });
            //    layui.form.render("select");
            //});

            //操作方式
            $.getJSON("/Assets/GetCode?type=operationMode", function (result) {
                $('#operationMode').append(new Option(top.lang.pleaseSelect, ""));
                let plat = result.data;
                plat.forEach(function (v) {
                    for (var key in top.lang) {
                        if (top.lang.hasOwnProperty(key)) {
                            if (key === v.remark) {
                                var text = top.lang[key];
                                $('#operationMode').append(new Option(text, v.remark));
                            }
                        }
                    }
                });
                layui.form.render("select");
            });

            ////我的钱包列表
            //$.getJSON("/Assets/GetCrmWallet", function (result) {
            //    $('#crmWallet').append(new Option(top.lang.pleaseSelect, ""));
            //    let plat = result.data;
            //    plat.forEach(function (v) {
            //        $('#crmWallet').append(new Option(v.currency, v.id))
            //    });
            //    layui.form.render("select");
            //});

            // 渲染表格
            renderTable = function () {
                table.render({
                    elem: '#table-datalist'
                    , url: '/Assets/GetWalleStatement'
                    , limit: 20
                    , title: '钱包流水'
                    , cols: [[
                        //{ field: 'index', title: '序号', type: 'numbers', width: 60, templet: '#zizeng' }
                        { field: 'orderNumber', title: '流水号' }
                        //, {
                        //    field: 'operationType', title: '操作类型', templet: function (res) {
                        //        return '<span lay-event="' + res.operationType + '"></span>';
                        //    }
                        //}
                        , {
                            field: 'operationMode', title: '操作方式', templet: function (res) {
                                return '<span lay-event="' + res.operationMode + '"></span>';
                            }
                        }
                        , { field: 'beforeAmount', title: '变动前金额' }
                        , { field: 'changeAmount', title: '变动金额' }
                        , { field: 'afterAmount', title: '变动后金额' }
                        , {
                            field: 'createTime', title: '创建时间', templet: function (res) {
                                return res.changeTime;
                            }
                        }
                        , { field: 'operate', fixed: 'right', title: '操作', toolbar: '#table-datalist-bar' }
                    ]]
                    , id: "tableReload"
                    , defaultToolbar: false
                    , page: { layout: ['prev', 'page', 'next', 'refresh'] }
                    , done: function (res) {
                        if (res.count == 0) {
                            $(".layui-table-main").html('<div class="layui-none">' + top.lang.noData + '</div>');
                        }
                        layer.closeAll('loading');
                        /**多语言初始化 */
                        top.SetListPageLanguage(layui);
                        layui.form.render("select");
                    }
                });
            };
            renderTable();

            //监听行工具事件
            table.on('tool(table-datalist)', function (obj) {
                var data = obj.data;
                if (obj.event === 'view') {
                    top.OpenPageByKey(layui, "walleStatement", 2, '90%', '90%', '/Assets/WalleStatementDetail?id=' + data.orderNumber);

                    //parent.layui.index.openTabsPage("/Assets/WalleStatementDetail?id=" + data.serialNumber);
                    ////初始化导航选项卡（选中新建标签卡）
                    //parent.layui.element.render('nav');
                }
            });

            //查询
            form.on('submit(search)', function (data) {
                //执行重载
                table.reload('tableReload', {
                    page: { curr: 1, layout: ['prev', 'page', 'next', 'refresh'] }
                    , where: {
                        operationMode: $("#operationMode option:selected").val(),
                        orderNumber: $("#orderNumber").val(),
                        changeTime: $("#changeTime").val()
                    }
                });
            });

            //重置
            form.on('submit(resetting)', function (data) {
                $("#operationMode option:selected").val('')
                $("#orderNumber").val('')
                $("#changeTime").val('')
                //执行重载
                table.reload('tableReload', {
                    page: { curr: 1, layout: ['prev', 'page', 'next', 'refresh'] }
                    , where: {
                        operationMode: "",
                        orderNumber: "",
                        changeTime: "",
                    }
                });
            });
        });

    </script>
}
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card" lay-filter="component-form-element">
                    <div class="layui-card-body layui-form layui-form-pane" style="padding: 15px;">
                        <div class="layui-form-item">
                            @* <div class="layui-inline">
                        <label class="layui-form-label" lay-event="operationType">操作类型</label>
                        <div class="layui-input-inline">
                        <select name="operationType" id="operationType">
                        </select>
                        </div>
                        </div>*@
                            <div class="layui-inline">
                                <label class="layui-form-label" lay-event="operationMode">操作方式</label>
                                <div class="layui-input-inline">
                                    <select name="operationMode" id="operationMode">
                                    </select>
                                </div>
                            </div>
                            @*  <div class="layui-inline">
                        <label class="layui-form-label" lay-event="crmWallet">钱包</label>
                        <div class="layui-input-inline">
                        <select name="crmWallet" id="crmWallet">
                        </select>
                        </div>
                        </div>*@
                            <div class="layui-inline">
                                <label class="layui-form-label" lay-event="orderNumber">订单号</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="orderNumber" name="orderNumber" placeholder="orderNumber" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label" lay-event="createTime">创建时间</label>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" id="changeTime" name="changeTime" placeholder="createTime" lay-key="8">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <button class="layui-btn" lay-submit lay-filter="search" lay-event="search">搜索</button>
                                    <button class="layui-btn layui-btn-primary" lay-submit lay-filter="resetting" lay-event="resetting">重置</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-card">
                    <div class="layui-card-body">
                        <div class="layui-tab-content">
                            <table class="layui-hide" id="table-datalist" lay-filter="table-datalist"></table>
                            @*       <script type="text/html" id="zizeng">
                        {{d.LAY_TABLE_INDEX+1}}
                        </script>*@
                            <script type="text/html" id="table-datalist-bar">
                                <button class="layui-btn layui-btn-sm" lay-event="view">查看</button>
                            </script>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

